import { createStore } from 'vuex';
import createPersistedState from "vuex-persistedstate";
import getters from './getters';
import permission from './modules/permission';
import settings from './modules/settings';
import system from './modules/system';
const vuexSS = createPersistedState({ key: "vue3_persistedstate", storage: window.sessionStorage, paths: ['permission', 'system'] });
const vuexSL = createPersistedState({ key: "vue3_persistedstate", storage: window.localStorage, paths: ['settings'] });

export default createStore({
  plugins: [vuexSS, vuexSL],
  state: {
    name:sessionStorage.getItem('name'),
    token:sessionStorage.getItem('token')
  },
  mutations: {
    updatename(state,payload){
      state.name = payload
      window.sessionStorage.setItem('name',payload)
    }
  },
  actions: {},
  getters: getters,
  modules: { permission, settings, system }
});
